<?php
//  ------------------------------------------------------------------------ //
//                          SHORTCUTS FOR XOOPS 2                            //
//                  Copyright (c) 2005-2006 Instant Zero                     //
//                     <http://xoops.instant-zero.com/>                      //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
include_once('header.php');
include_once(XOOPS_ROOT_PATH.'/header.php');
include_once XOOPS_ROOT_PATH.'/modules/shortcuts/include/functions.php';

if(!is_object($xoopsUser)) {
	redirect_header(XOOPS_URL.'/index.php', 2, _SHORTCUTS_REGISTRED);
}

$uid = $xoopsUser->getVar('uid');
$urlid = 0;
$urlid = isset($_POST['selshort']) ? intval($_POST['selshort']) : 0;
if($urlid == 0) {
	$urlid=isset($_GET['selshort']) ? intval($_GET['selshort']) : 0;
}

$shortcuts_handler =& xoops_getmodulehandler('shortcuts', 'shortcuts');

if($urlid) {
	$myshortcuts = $shortcuts_handler->get($urlid);
	if($myshortcuts->getVar('uid') != $xoopsUser->getVar('uid')) {
		redirect_header(XOOPS_URL.'/index.php', 2, _ERRORS);
	}
	if(st_getmoduleoption('savehits')) {
		$myshortcuts->UpdateUrlHits();
	}
	if(st_getmoduleoption('useredirect')) {
		redirect_header($myshortcuts->getVar('url'), 1, $myshortcuts->getVar('title'));
	} else {
		header('Location: '.$myshortcuts->getVar('url'));
	}
} else {
	redirect_header(XOOPS_URL.'/index.php', 2, _SHORTCUTS_ADD_AN_ENTRY);
}
include_once(XOOPS_ROOT_PATH.'/footer.php');
?>